#include<stdio.h>
#include<conio.h>
int a[20],n,i,j;
float s,c[20][20],A[20];
void input(){
    printf(" Nhap cap n : ");scanf("%d",&n);
    for(i=0;i<=n;i++){
        printf("Nhap a[%2d] = ",i);
        scanf("%d",&a[i]);
    }
    
}
void processing(){
    printf("____________________________________________________\n");
    printf("|                                                   \n");
    printf("|\t| s^%d\t|",n);
    for(i=0;i<=n/2;i++){
        c[1][i+1]=a[i*2];
        printf(" %g\t|",c[1][i+1]);
    }
    printf("\n|\t| s^%d\t|",n-1);
    for(i=0;i<=n/2;i++){
        c[2][i+1]=a[i*2+1];
        printf(" %g\t|",c[2][i+1]);
    }
    for(i=3;i<=n+1;i++){
        A[i]=c[i-2][1]/c[i-1][1];
        printf("\n| %2.2f\t| s^%d \t|",A[i],n-i+1);
        for(j=1;j<=n/2;j++){
            c[i][j]=c[i-2][j+1]-A[i]*c[i-1][j+1];
            printf(" %2.2f\t|",c[i][j]);
        }
    }
    printf("\nKet luan : \n ");
    i=0;
    for(j=4;j<=n+1;j++){
        if(A[j]*A[j-1]<0)i++;
    }
    if(i==0)
        if(A[3]>0)printf("Cot 1 tat ca deu duong nen tat ca cac nghiem cua phuong trinh dac trung nam ben trai mat phang phuc");
        else printf("Khong co nghiem nam ben phai mat phang phuc");
    else printf("So nghiem nam ben phai mat phang phuc la %d",i);
}
int main(){
    input();
    processing();
    getch();
    return 0;
}
    
    
